﻿using Shinva.LADModel.Abstractions;
using Shinva.Variables.Interface;
using Shinva.Variables.Models;
using Shinva.Variables.Type.bit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shinva.LADModel.Type.Mathfunctions
{
    public class IncDec<T> : ElementNodeBase where T : IPlcMember
    {
        public T operand { get; set; }

        private bool _inc = true; //默认为累加

        public override PlcBool EN
        {
            get
            {
                return en;
            }
            set
            {
                en = value;
            }
        }
        public override PlcBool ENO
        {
            get
            {

                eno.Value = en.Value && IncDecValue();
                return eno;
            }
            set
            {
                eno = value;
            }
        }

        public IncDec(bool incDec=true)
        {
            Name = "IncDec";
            _inc = incDec;
            variableTableInterface.AddVariable("operand", StorageType.InOut);
            operand = variableTableInterface.GetVariableValue<T>("operand");
        }

        

        public override IPlcMember GetInterfaceVariableByName(string name)
        {
            return variableTableInterface.GetVariableValue<IPlcMember>(name);
        }
        public bool IncDecValue()
        {
            return false;
        }
    }
}
